package com.freesky.provider.search.controller;

import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.provider.search.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 17:00 2018/11/29
 * @description:
 */
@RestController
public class SearchController {
    @Autowired
    private ISearchService searchService;


    @GetMapping(value = "/item/search")
    public JSONResponse searchProduct(@RequestParam(defaultValue = "") String key,
                                      @RequestParam(defaultValue = "1") int page,
                                      @RequestParam(defaultValue = "20") int size,
                                      @RequestParam(defaultValue = "") String sort,
                                      @RequestParam(defaultValue = "-1") int priceGt,
                                      @RequestParam(defaultValue = "-1") int priceLte) {

        return searchService.search(key, page, size, sort, priceGt, priceLte);
    }


    @GetMapping(value = "/item/search/item_name_list")
    public JSONResponse getItemNameListByKeyWords(@RequestParam(value = "key",defaultValue = "") String key) {
        return searchService.getItemNameListByKeyWords(key);
    }
}
